home *** CD-ROM | disk | FTP | other *** search
- Path: news.microsoft.com!news
- From: a-cnadc@microsoft.com (Dann Corbit)
- Newsgroups: comp.lang.c
- Subject: Re: Simple Program Question
- Date: 27 Feb 1996 03:30:20 GMT
- Organization: Microsoft Corporation
- Message-ID: <4gttsc$2pr@news.microsoft.com>
- References: <4gsr9u$sk6@newsbf02.news.aol.com>
- NNTP-Posting-Host: 157.57.171.202
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.14
-
- In article <4gsr9u$sk6@newsbf02.news.aol.com>, tycope@aol.com says...
- >
- >I am trying to write a non -interactive program that calculates all
- >integer triples (i, j, k) such that
- >0 < i < j < k < l and i + j + k = l. Print out the number of triples that
- >satisfy the requirements and print out every millionth triple. Can anyone
- >see where I am missing the boat in the following code. The program runs
- >and immediately terminates. Thanks in advance for any feedback.
- >
- >#include <stdio.h>
- >
- >long int i, j, k, l;
- >long int count;
- >
- >int
- >main (void)
- >{
- > do
- > {
- > (l = i + j + k);
-
- ^^^^^^^^^^
- Hint: What do i, j, and k contain right here?
-
- > (i = 1);
- > (j = 2);
- > (k = 3);
- > (i++, j++, k++);
- > (++count);
- > if (count % 1000000 == 0)
- > {
- > printf("%ld(i) + %ld(j) + %ld(k) = %ld(l)", i, j, k, l);
- > }
- >
- > } while (0 < i < j < k < l);
- >
- > return (0);
- >}
-
- --
- The opinions expressed in this message are my own personal views
- and do not reflect the official views of Microsoft Corporation.
- In fact, I'm just a subcontractor, not an employee, so pull in your claws.
-
-